Skip to content

Conversation

@klausler
Copy link
Contributor

The ISO Fortran standards don't say whether a WRITE to a formatted stream unit should truncate the unit if there has been any repositioning (via POS= control list specifiers) to an earlier point in the stream. But units with sequential records do truncate on writes after BACKSPACE and REWIND statements, and many compilers (including this one) truncate stream units too. Since some compilers don't truncate streams, this patch adds an environment variable FORT_TRUNCATE_STREAM that can be set to 0 to disable truncation and ease porting to flang-new of codes that depend on that behavior.

Fixes #167569.

The ISO Fortran standards don't say whether a WRITE to a formatted
stream unit should truncate the unit if there has been any
repositioning (via POS= control list specifiers) to an earlier
point in the stream.  But units with sequential records do truncate
on writes after BACKSPACE and REWIND statements, and many compilers
(including this one) truncate stream units too.  Since some
compilers don't truncate streams, this patch adds an environment
variable FORT_TRUNCATE_STREAM that can be set to 0 to disable
truncation and ease porting to flang-new of codes that depend
on that behavior.

Fixes llvm#167569.
@llvmbot llvmbot added the flang Flang issues not falling into any other category label Nov 17, 2025
@github-actions
Copy link

🐧 Linux x64 Test Results

  • 254 tests passed
  • 1 test skipped

@klausler klausler merged commit a55e30b into llvm:main Nov 19, 2025
13 checks passed
@klausler klausler deleted the bug167569 branch November 19, 2025 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[flang] DTIO: stream access with pos= specifier not working properly

3 participants